package collision;

import gameObjects.SolidSpaceObject;
import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.SpriteGroup;
import com.golden.gamedev.object.collision.BasicCollisionGroup;

public class BasicCollision extends BasicCollisionGroup {
    public BasicCollision() {

    }

    public BasicCollision(SpriteGroup s1, SpriteGroup s2) {
        setCollisionGroup(s1, s2);
    }

    @Override
    public void collided(Sprite s1, Sprite s2) {
        if ((s1 instanceof SolidSpaceObject) && (s2 instanceof SolidSpaceObject)) {
            solidCollision((SolidSpaceObject) s1, (SolidSpaceObject) s2);

        }
        else {
            s1.setActive(false);
            s2.setActive(false);
        }
    }

    public void solidCollision(SolidSpaceObject s1, SolidSpaceObject s2) {
        s1.takeDamage(s2.getDamage());
        s2.takeDamage(s1.getDamage());
    }

}
